package com.dancun.service.impl;

import com.dancun.entity.CTask;
import com.dancun.entity.TGroup;
import com.dancun.mapper.CTaskMapper;
import com.dancun.mapper.TGroupMapper;
import com.dancun.service.ITGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-10-02
 */
@Service
public class TGroupServiceImpl extends ServiceImpl<TGroupMapper, TGroup> implements ITGroupService {


    @Autowired
    TGroupMapper tGroupDao;

    @Autowired
    CTaskMapper cTaskDao;

    public List<TGroup> listByStu(String stno){
        return  tGroupDao.listByStu(stno);
    }

    @Override
    public List<TGroup> listByName(String id) {

        // TODO Auto-generated method stub
        List<TGroup> list = tGroupDao.listByStu(id);
        List<CTask> listTask = new ArrayList<CTask>();
        if(list!=null&&list.size()!=0) {
            for(int i=0;i<list.size();i++) {
                CTask task = (CTask) cTaskDao.selectById(list.get(i).getTaskId());
                list.get(i).setCTask(task);
            }
        }

        return list;
    }
}
